package com.app.mapper;

import com.app.model.TenantRelationship;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 承租人关系记录表 Mapper 接口
 * </p>
 *
 * @author yoominic
 * @since 2025-03-14
 */
public interface TenantRelationshipMapper extends BaseMapper<TenantRelationship> {

    IPage<TenantRelationship> queryTenanRelationship(Page<TenantRelationship> page,@Param("isRealName") String isRealName,
                                                     @Param("status")String status,@Param("haveNewDeposit")String haveNewDeposit,
                                                     @Param("houseType")String houseType,@Param("fwkeyword")String fwkeyword,
                                                     @Param("yhkeyword")String yhkeyword);

    TenantRelationship getTenantRelationshipInfoById(Integer id);

    @Select("select \n" +
            "    tr.*,\n" +
            "    f.id as fwId,\n" +
            "    f.lease_certificate_number_new as leaseCertificateNumberNew,\n" +
            "    f.area_name as areaName,\n" +
            "    f.street_name as streetName\n" +
            "from  tb_tenant_relationship tr \n" +
            "left join  fw f on f.id_value = tr.unique_id \n" +
            "where  1=1 and tr.tenant_id_card = #{tenantIdCard}")
    List<TenantRelationship> getTenantRelationshipByTenantIdCard(@Param("tenantIdCard") String tenantIdCard);



    @Select("  ")
    List<TenantRelationship> getTenantRelationshipByLeaseCertificateNumber(Page<TenantRelationship> page,@Param("isRealName") String isRealName,
                                                                           @Param("status")String status,@Param("haveNewDeposit")String haveNewDeposit,
                                                                           @Param("houseType")String houseType,@Param("fwkeyword")String fwkeyword,
                                                                           @Param("yhkeyword")String yhkeyword);


}
